package com.shujia.wyh.day07.homework;

import java.util.Scanner;

/*
        2.根据成绩输出对应的等级，使用if多分支和switch语句分别实现。
        a)A级   [90,100]
        b)B级   [80,90)
        c)C级   [70,80)
        d)D级   [60,70)
        e)E级   [0,60)
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生的成绩：");
        int score = sc.nextInt();

        System.out.println("=============if语句实现=====================");
        if (score >= 90 & score <= 100) {
            System.out.println("A级");
        } else if (score >= 80 & score < 90) {
            System.out.println("B级");
        } else if (score >= 70 & score < 80) {
            System.out.println("C级");
        } else if (score >= 60 & score < 70) {
            System.out.println("D级");
        } else if (score >= 0 & score < 60) {
            System.out.println("E级");
        } else {
            System.out.println("输入的成绩有误！！");
        }
        System.out.println("============switch语句实现============= ");
        String grade = null;
        if(score>=0 & score<=100){
            int a = score / 10;
            switch (a) {
                case 10:
                case 9:
                    grade = "A";
                    break;
                case 8:
                    grade = "B";
                    break;
                case 7:
                    grade = "C";
                    break;
                case 6:
                    grade = "D";
                    break;
                default:
                    grade = "E";
                    break;
            }
            System.out.println("最终成绩等级：" + grade);
        }else {
            System.out.println("输入成绩有误！");
        }



    }
}
